package com.example.springboott1.config;

import com.example.springboott1.config.interceptor.JwtInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorAdapterConfig  implements WebMvcConfigurer {

    private final JwtInterceptor jwtInterceptor;

    public InterceptorAdapterConfig(JwtInterceptor jwtInterceptor) {
        this.jwtInterceptor = jwtInterceptor;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry)
    {
        //注册自己的拦截器并设置拦截的请求路径
        registry.addInterceptor(jwtInterceptor).addPathPatterns("/admin/getToken").addPathPatterns("/");
    }
}
